<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>settle_account</title>


  <!-- 日期选择器引入依赖 -->

  <!--  -->

  <link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="dist/css/adminlte.min.css">
  <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
  <link type="text/css" rel="stylesheet" charset="UTF-8"
    href="https://translate.googleapis.com/translate_static/css/translateelement.css">
  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet"
    href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome Icons -->
  <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
  <!-- IonIcons -->
  <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="dist/css/adminlte.min.css">

  <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
  <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
</head>
<!--
`body` tag options:

  Apply one or more of the following classes to to the body tag
  to get the desired effect

  * sidebar-collapse
  * sidebar-mini
-->

<body class="hold-transition sidebar-mini">
  <div class="wrapper" id="app1">
    <div class="content">
      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card card-default" id="add_card" style="display: none;">
              <div class="card-header">
                <h3 class="card-title">
                  <font style="vertical-align: inherit;">
                    <font style="vertical-align: inherit;">Select2（默认主题）</font>
                  </font>
                </h3>
                <div class="card-tools">
                  <button onclick="addsettlelist()" type="button" class="btn btn-primary"> 提交</button> &nbsp;
                  <button type="button" class="btn btn-primary">
                    Action
                  </button>
                  <button type="button" class="btn btn-tool" data-card-widget="collapse"><i
                      class="fas fa-minus"></i></button>
                  <button onclick="drop_add()" type="button" class="btn btn-tool"><i class="fas fa-times"></i></button>
                </div>
              </div>
              <!-- /.card-header -->
              <div class="card-body">
                <div class="row">
                  <div class="col-md-4">
                    <div class="row">
                      <div class="col-md-3">
                        <p>单号：</p><br>
                        <p>类型：</p><br>
                      </div>
                      <div class="col-md-9">
                        <input id="form" type="text" placeholder="--"
                          style="width: 200px; height: 35px; display: block;" value="ps123123"><br>
                        <ul class="navbar-nav nav-sidebar ">
                          <li class="nav-item d-none d-sm-inline-block">
                            <select id="types" class="selectpicker show-tick form-control" style="width: 200px;">
                              <option>销售</option>
                              <option>退货</option>
                            </select>
                          </li>
                        </ul> <br>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-4">
                    <div class="row">
                      <div class="col-md-3">
                        <p>包裹名称：</p><br>
                        <p>状态：</p><br>
                      </div>
                      <div class="col-md-9">
                        <ul class="navbar-nav nav-sidebar ">
                          <li class="nav-item d-none d-sm-inline-block">
                            <select id="pack_name" class="selectpicker show-tick form-control" style="width: 200px;">
                              <option v-for="cup in cups"><span>{{cup.upid}}</span></option>
                            </select>
                          </li>
                        </ul><br>
                        <ul class="navbar-nav nav-sidebar ">
                          <li class="nav-item d-none d-sm-inline-block">
                            <select id="status" class="selectpicker show-tick form-control" style="width: 200px;">
                              <option>0</option>
                              <option>1</option>
                            </select><br>
                          </li>
                        </ul>
                      </div>
                    </div>
                  </div>
                  <div class="col-md-4">
                    <div class="row">
                      <div class="col-md-3">
                        <p>制单时间：</p><br>
                      </div>
                      <div class="col-md-9">
                        <input id="time" type="datetime-local" style="width: 200px; height: 35px; display: block;"><br>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <div class="card">
              <div class="card-header border-0">
                <nav class=" navbar navbar-expand navbar-white navbar-light">
                  <ul class="navbar-nav nav-sidebar ">
                    <li class="nav-item d-none d-sm-inline-block">
                      <a onclick="goinadd()" href="#" class="nav-link">
                        <i class="fas fa-plus nav-icon"></i>
                        <p>新增单</p>
                      </a>
                    </li>
                    <li class="nav-item d-none d-sm-inline-block">
                      <a href="#" class="nav-link">
                        <i class="fas  fa-random nav-icon"></i>
                        <p>导出</p>
                      </a>
                    </li>
                  </ul>
                </nav>
              </div>
              <div class="card-body">
                <div id="example1_wrapper" class="dataTables_wrapper dt-bootstrap4">
                  <div class="row">
                    <div class="col-sm-12">
                      <table id="example1" class="table table-bordered table-striped dataTable dtr-inline" role="grid"
                        aria-describedby="example1_info">
                        <thead>
                          <tr role="row">
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                              aria-label="Rendering engine: activate to sort column ascending">序号</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                              aria-label="Browser: activate to sort column ascending" style="">单号</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                              aria-label="Browser: activate to sort column ascending" style="">类型</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                              aria-label="Platform(s): activate to sort column ascending" style="">状态</th>
                            <th class="sorting_desc" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                              aria-label="Engine version: activate to sort column ascending" aria-sort="descending"
                              style="">制单时间</th>
                            <th class="sorting" tabindex="0" aria-controls="example1" rowspan="1" colspan="1"
                              aria-label="CSS grade: activate to sort column ascending" style="">操作</th>
                          </tr>
                        </thead>
                        <tbody>
                          <tr role="row" class="odd" style="display: none;">
                            <td class="" tabindex="0">Gecko</td>
                            <td style="">Epiphany 2.20</td>
                            <td style="">Gnome</td>
                            <td style="">Epiphany 2.20</td>
                            <td style="">Gnome</td>
                            <td style="">
                              <button type="button" class="btn btn-default dropdown-toggle dropdown-icon"
                                data-toggle="dropdown">
                                <span class="sr-only">Toggle Dropdown</span>
                                <div class="dropdown-menu" role="menu">
                                  <a class="dropdown-item" href="#">编辑</a>
                                </div>
                              </button>
                            </td>
                          </tr>
                          <tr role="row" class="odd" v-for="(settleaccount,index) in settleaccounts">
                            <td>{{index+1}}</td>
                            <td>{{settleaccount.sanu}}</td>
                            <td>{{settleaccount.types}}</td>
                            <td>{{settleaccount.status}}</td>
                            <td>{{settleaccount.time}}</td>
                            <td>
                              <button type="button" class="btn btn-default dropdown-toggle dropdown-icon"
                                data-toggle="dropdown">
                                <span class="sr-only">Toggle Dropdown</span>
                                <div class="dropdown-menu" role="menu">
                                  <a class="dropdown-item" href="#">编辑</a>
                                </div>
                              </button>
                            </td>
                          </tr>
                        </tbody>
                        <tfoot>
                        </tfoot>
                      </table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <!-- ./wrapper -->

  <!-- REQUIRED SCRIPTS -->

  <!-- jQuery -->
  <script src="plugins/jquery/jquery.min.js"></script>
  <!-- Bootstrap -->
  <script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
  <!-- AdminLTE -->
  <script src="dist/js/adminlte.js"></script>

  <!-- OPTIONAL SCRIPTS -->
  <script src="plugins/chart.js/Chart.min.js"></script>
  <!-- AdminLTE for demo purposes -->
  <script src="dist/js/demo.js"></script>
  <!-- AdminLTE dashboard demo (This is only for demo purposes) -->
  <script src="dist/js/pages/dashboard3.js"></script>
  <!--  -->

  <script src="plugins/datatables/jquery.dataTables.min.js"></script>
  <script src="plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
  <script src="plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
  <script src="plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
  <script src="dist/js/adminlte.min.js"></script>

  <script>
    function goinadd() {
      document.getElementById("add_card").style.display = "";
    };
    function drop_add() {
      document.getElementById("add_card").style.display = "none";
    };
    function addsettlelist() {


      var form = $("#form").val();
      var types = $("#types").val();
      var pack_name = $("#pack_name").val();

      var status = $("#status").val();

      var time = $("#time").val();

      var time2 = time.split("T");
      time2 = time2[0] + time2[1];
      alert(time2);

      time = new Date(time);



      var tr = $("<tr></tr>");;

      $.ajax({
        url: "settleaccount/add",
        type: "post",
        data: {

          "sanu": form,
          "types": types,
          "upid": pack_name,

          "status": status,
          "time": time,
          "paid": pack_name


        },
        success: function (res) {
          console.log(res);
        }
      });


      var form1 = $("<td></td>").text(form);
      var types1 = $("<td></td>").text(types);


      var status1 = $("<td></td>").text(status);
      var time1 = $("<td></td>").text(time2);


      tr.append($("#example1").find("tr").length);
      tr.append(form1);

      tr.append(types1);
      tr.append(status1);

      tr.append(time1);
      tr.append("<button type='button' class='btn btn-default dropdown-toggle dropdown-icon' data-toggle='dropdown'><span class='sr-only'>Toggle Dropdown</span><div class='dropdown-menu' role='menu'><a   class='dropdown-item' href='#'>编辑</a></div></button>");

      $("#example1").append(tr);
    }
  </script>
  <script>
    new Vue({
      el: "#app1",
      data: {
        settleaccounts: [],
        unpacks: [],
        cups: []
      },
      mounted() {
        axios
          .get('settleaccount/all')
          .then(res => {
            console.info(res.data);
            this.settleaccounts = res.data.data;

          }),
          axios
            .get('unpack/all')
            .then(res => {
              console.info(res.data);
              this.unpacks = res.data.data;

              for (var i = 0; i < this.unpacks.length; i++) {

                if (this.unpacks[i].status == 0) {

                  this.cups.push(this.unpacks[i]);
                }
              }

              console.log(this.cups);
            })

      },
      methods: {

      }
    });
  </script>





  <script>
    $(function () {
      $("#example1").DataTable({
        "responsive": true,
        "autoWidth": false,
      });
      $('#example2').DataTable({
        "paging": true,
        "lengthChange": false,
        "searching": false,
        "ordering": true,
        "info": true,
        "autoWidth": false,
        "responsive": true,
      });
    });
  </script>

</body>

</html>